package com.epam.epamtest.config;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import static com.epam.epamtest.config.Constants.*;

@Component
@Aspect
public class LimiterAspect {

    @Pointcut("@annotation(com.epam.epamtest.config.RateLimit)")
    public void LimiterAspect() {
    }

    @Before("LimiterAspect()")
    public void beforeMethod(JoinPoint jp) {
        RATE_LIMITER.acquire();
    }
}
